<extend name="Common@Layout:hui-admin" />
<block name="title"><title>Administator管理后台</title></block>
<block name="style">

</block>

<block name="main">
<div class="pd-20">
	<form action="{:u('Lessonadmin/edit_post')}" method="post" class="form form-horizontal validator_form close-dialog" id="form-article-add">
		 
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>校区：</label>
			<div class="formControls col-8">
			  <span class="select-box inline">
					<select name="did" id="district" class="select">
						{$districtoptions}
					</select>
				</span>
			</div>
			<div class="col-2"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>班级：</label>
			<div class="formControls col-8">
			  <span class="select-box inline">
					<select name="cid" id="class" class="select" data-cid="{$info.cid}">
					</select>
				</span>
			</div>
			<div class="col-2"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>课堂类型：</label>
			<div class="formControls col-8">
			  <span class="select-box inline">
			  		 <php>$lesson_type = C('LESSON_TYPE');</php>
					<select name="lessontype" class="select">
						<foreach name="lesson_type" item="vo">
						   <option value="{$key}" <if condition="$info['lessontype'] eq $key">selected</if>>{$vo}</option>
						 </foreach>
					</select>
				</span>
			</div>
			<div class="col-2"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>课堂代码：</label>
			<div class="formControls col-2">
			  	<input type="text" class="input-text" value="{$info.lessoncode}" placeholder="" name="lessoncode"  data-rule="课堂代码:required;">
			</div>
			<div class="col-4"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>课堂对象（岁）：</label>
			<div class="formControls col-2">
			  	<input type="text" class="input-text" value="{$info.lessontarget}" placeholder="" name="lessontarget"  data-rule="课堂对象:required;">
			</div>
			<div class="col-4"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>上课时间：</label>
			<div class="formControls col-4">
			  	<input type="text" class="input-text" value="{$info.lessontime}" placeholder="" name="lessontime"  data-rule="上课时间:required;">
			</div>
			<div class="col-4"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>名额：</label>
			<div class="formControls col-2">
			  	<input type="text" class="input-text" value="{$info.number}" placeholder="" name="number"  data-rule="名额:required;integer[+]">
			</div>
			<div class="col-4"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>总课时：</label>
			<div class="formControls col-2">
			  	<input type="text" class="input-text" value="{$info.worktotal}" placeholder="" name="worktotal"  data-rule="总课时:required;integer[+];filter">
			</div>
			<label class="form-label col-2"><span class="c-red">*</span>课次：</label>
			<div class="formControls col-2">
			  	<input type="text" class="input-text" value="{$info.worknum}" placeholder="" name="worknum"  data-rule="课次:required;integer[+];filter">
			</div>
			<div class="col-4"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>单价：</label>
			<div class="formControls col-2">
			  	<input type="text" class="input-text" value="{$info.price}" placeholder="" name="price"  data-rule="单价:required;price;" data-rule-price="[/^\d{1,10}(\.\d{1,2})?$/,'格式不正确']" >
			</div>
			<label class="form-label col-2"><span class="c-red">*</span>材料费：</label>
			<div class="formControls col-2">
			  	<input type="text" class="input-text" value="{$info.materialcost|default='0'}" placeholder="" name="materialcost"  data-rule="材料费:required;price;" data-rule-price="[/^\d{1,10}(\.\d{1,2})?$/,'格式不正确']">
			</div>
			<div class="col-4"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>总价：</label>
			<div class="formControls col-2">
			  	<input type="text" class="input-text" value="{$info.total}" placeholder="" name="total"  data-rule="总价:required;price;" data-rule-price="[/^\d{1,10}(\.\d{1,2})?$/,'格式不正确']">
			</div>
			<div class="col-4"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2">优惠(元)：</label>
			<div class="formControls col-2">
			  	<input type="text" class="input-text" value="{$info.discount}" placeholder="" name="discount">
			</div>
			<label class="form-label col-2">老生折扣（%）：</label>
			<div class="formControls col-2">
			  	<input type="text" class="input-text" value="{$info.oidstudentdiscount}" placeholder="" name="oidstudentdiscount">
			</div>
			<div class="col-4"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-2">备注：</label>
			<div class="formControls col-10">
				<textarea name="desc" cols="" rows="" class="textarea"  placeholder="说点什么...最少输入10个字符" datatype="*10-100" dragonfly="true" nullmsg="备注不能为空！" onKeyUp="textarealength(this,200)">{$info.desc}</textarea>
				<p class="textarea-numberbar"><em class="textarea-length">0</em>/200</p>
			</div>
		</div>
	  	<div class="row cl">
	    	<div class="col-9 col-offset-2">
	    		<input type="hidden" name="id" value="{$info['id']}">
	      		<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
	    	</div>
	  	</div>
	</form>
</div>
</block>

<block name="script">
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$('.mini-time').datepicker();
	
	get_class();
	
});

$("input[name='worknum']").blur(function(){
	get_total();
});
$("input[name='price']").blur(function(){
	get_total();
});
$("input[name='materialcost']").blur(function(){
	get_total();
});

function get_total(){
	var total;
	var worknum = $("input[name='worknum']").val();//课次
	var price = $("input[name='price']").val();//单价
	var materialcost = $("input[name='materialcost']").val();//材料费
	if(worknum !=='' && price !=='' && materialcost!==''){
		total = (parseFloat(price)+parseFloat(materialcost))*parseInt(worknum);
		$("input[name='total']").val(total);
	}
}

function get_class(){
	var html = selected = '';
	var did = $("#district").val();
	var cid = $("#class").attr("data-cid");
	$.post("/Ygcl/Classadmin/get_class",{did:did},function(data){
		if(data.status){
			var obj = data.info;
			for ( var p in obj ){
				if(cid == obj[p]['id']){
					selected = 'selected';
				}else{
					selected = '';
				}
				html +='<option value="'+obj[p]['id']+'" '+selected+'>'+obj[p]['title']+'</option>';
			}
			$("#class").empty().append(html);
		}else{
			$("#class").empty();
		}
	})
}
$("#district").change(function(){
	get_class();
})
</script>
</block>